# Copyright (c) 2020 Presto Labs Pte. Ltd.
# Author: xguo

import datetime
import json
import sys


def get_hs_time(timestamp):
  return datetime.datetime.fromtimestamp(timestamp / 1e9).strftime('%Y%m%d %H:%M:%S.%f')


def main(argv):
  filename = argv[1]
  with open(filename) as infile:
    data = json.load(infile)

  for each in data:
    each['human_readable_timestamp'] = get_hs_time(each['ts'])

  with open(filename, 'w') as outfile:
    json.dump(data, outfile, indent=2)


if __name__ == '__main__':
  main(sys.argv)
